package app;

import app.controller.IndexController;
import app.controller.StatisticController;
import app.util.Filters;
import app.util.Path;


public class Application {

    public static void main(String[] args) {
        // configure spark
        // spark.Spark.ipAddress("192.168.0.109");
        spark.Spark.staticFiles.location("/public");
        spark.Spark.staticFiles.expireTime(600L);
        // set up before filters
        //before("*", Filters.addTrailingSlashes);
        //before("*", Filters.handleLocaleChange);
        // set up routes
        spark.Spark.redirect.get(Path.Web.ROOT, Path.Web.LIST);
        spark.Spark.get(Path.Web.LIST, IndexController.serveListPage);
        spark.Spark.post(Path.Web.ADD, IndexController.serveAddPage);
        spark.Spark.post(Path.Web.DEL, IndexController.serveDelPage);
        spark.Spark.get(Path.Web.BOOKS, IndexController.serveBooksRequest);
        spark.Spark.get(Path.Web.BOOKCOUNTBYDATE, IndexController.serveBookCountByDateRequest);

        spark.Spark.get(Path.Web.STATISTIC, StatisticController.serveStatisticPage);
        spark.Spark.get(Path.Web.STRESULT, StatisticController.serveSTResultRequest);
        spark.Spark.get(Path.Web.BOOKSBYMONTH, StatisticController.serveSTResultBooksByMonth);
        // set up after filters
        spark.Spark.after("*", Filters.addGzipHeader);

    }

}
